<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>shake-invalid-input</title>
    <style>
        .shake-input {
            border: 1px solid #afafaf;
            padding: 10px 15px;
            outline: none;
            border-radius: 6pc;
            color: #535455;
        }
        .shake-input:focus {
            border-color: #2396ef;
        }
        .shake-input:invalid {
            box-shadow: 0 0 0.6rem #f8bcbc;
            animation: shake .4s ease-in 0s 2;
        }
        @keyframes shake {
            0% {
                margin-left: 0;
            }
            25% {
                margin-left: 0.5rem;
            }
            75% {
                margin-left: -0.5rem;
            }
            100% {
                margin-left: 0;
            }
        }
    </style>
</head>
<body>
    <input type="text" class="shake-input" placeholder="Letters only" pattern="[a-zA-Z]*">
</body>
</html>